package b.b;

import android.os.Build.VERSION;
import android.text.TextUtils;
import android.util.Log;
import android.util.LongSparseArray;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import b.b.h.i0;
import b.b.h.m0;
import java.lang.reflect.Field;

public final class a {
    public static Field a;
    public static boolean b;
    public static Class<?> c;
    public static boolean d;
    public static Field e;
    public static boolean f;
    public static Field g;
    public static boolean h;

    public static void a(Object obj) {
        String str = "ResourcesFlusher";
        if (!d) {
            try {
                c = Class.forName("android.content.res.ThemedResourceCache");
            } catch (ClassNotFoundException e) {
                Log.e(str, "Could not find ThemedResourceCache class", e);
            }
            d = true;
        }
        Class cls = c;
        if (cls != null) {
            Field declaredField;
            if (!f) {
                try {
                    declaredField = cls.getDeclaredField("mUnthemedEntries");
                    e = declaredField;
                    declaredField.setAccessible(true);
                } catch (NoSuchFieldException e2) {
                    Log.e(str, "Could not retrieve ThemedResourceCache#mUnthemedEntries field", e2);
                }
                f = true;
            }
            declaredField = e;
            if (declaredField != null) {
                LongSparseArray longSparseArray = null;
                try {
                    longSparseArray = (LongSparseArray) declaredField.get(obj);
                } catch (IllegalAccessException e3) {
                    Log.e(str, "Could not retrieve value from ThemedResourceCache#mUnthemedEntries", e3);
                }
                if (longSparseArray != null) {
                    longSparseArray.clear();
                }
            }
        }
    }

    public static InputConnection b(InputConnection inputConnection, EditorInfo editorInfo, View view) {
        if (inputConnection != null && editorInfo.hintText == null) {
            for (ViewParent parent = view.getParent(); parent instanceof View; parent = parent.getParent()) {
                if (parent instanceof m0) {
                    editorInfo.hintText = ((m0) parent).a();
                    break;
                }
            }
        }
        return inputConnection;
    }

    public static void c(View view, CharSequence charSequence) {
        if (VERSION.SDK_INT >= 26) {
            view.setTooltipText(charSequence);
            return;
        }
        i0 i0Var = i0.j;
        if (i0Var != null && i0Var.a == view) {
            i0.c(null);
        }
        if (TextUtils.isEmpty(charSequence)) {
            i0 i0Var2 = i0.k;
            if (i0Var2 != null && i0Var2.a == view) {
                i0Var2.b();
            }
            view.setOnLongClickListener(null);
            view.setLongClickable(false);
            view.setOnHoverListener(null);
            return;
        }
        i0Var = new i0(view, charSequence);
    }
}
